/*
 * Copyright (c) 2010-2011 NutShell.
 * [Project:YAM,Id:Department.java  2011-10-03 17:52:07 poplar.mumu ]
 */
package org.mumu.pawn.domain;

import org.hibernate.validator.constraints.Length;
import org.jboss.seam.solder.core.Veto;
import org.mumu.pawn.fm.annotation.OrderByColumn;
import org.richfaces.component.SortOrder;

import javax.persistence.*;
import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * 部门信息表 实体
 * <br/>
 *
 * @author poplar.mumu
 * @version 1.0 2011-10-03 17:52:07
 * @since JDK 1.5
 */
@Entity
@Table(name = "DEPARTMENT")
@Veto
public class Department implements Serializable {
    private static final long serialVersionUID = -2697646730103199826L;
    /*
    *主键
    */
    private long id;
    /*
     *部门名称
     */
    @OrderByColumn
    private String depName;
    /*
     *部门标识
     */
    private String depSign;
    /*
     *部门描述
     */
    private String depDesc;
    /*
     *创建时间
     */
    @OrderByColumn(order = SortOrder.ascending)
    private long createTime;
    /*
     *创建人
     */
    private long createActor;
    /*
     *修改时间
     */
    @OrderByColumn
    private long updateTime;
    /*
     *修改人
     */
    private long updateActor;
    /*
     *排序
     */
    private int sort;

    /**
     * 部门用户
     */
    private Set<User> users = new LinkedHashSet<User>();


    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
    @JoinTable(name = "USR_DEP",
            joinColumns = @JoinColumn(name = "USR_ID",unique = true,nullable = true),
            inverseJoinColumns = @JoinColumn(name = "DEPARTMENT_ID",unique = true,nullable = true))
    public Set<User> getUsers() {
        return users;
    }

    public void setUsers(Set<User> users) {
        this.users = users;
    }

    /**
     * @return 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public long getId() {
        return id;
    }

    /**
     * 设置 主键[ID]
     *
     * @param id 主键
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * @return 部门名称
     */
    @Column(name = "DEP_NAME")
    @Length(max = 15, min = 1)
    public String getDepName() {
        return depName;
    }

    /**
     * 设置 部门名称[DEP_NAME]
     *
     * @param depName 部门名称
     */
    public void setDepName(String depName) {
        this.depName = depName;
    }

    /**
     * @return 部门标识
     */
    @Column(name = "DEP_SIGN")
    @Length(max = 15, min = 1)
    public String getDepSign() {
        return depSign;
    }

    /**
     * 设置 部门标识[DEP_SIGN]
     *
     * @param depSign 部门标识
     */
    public void setDepSign(String depSign) {
        this.depSign = depSign;
    }

    /**
     * @return 部门描述
     */
    @Column(name = "DEP_DESC")
    @Length(max = 500)
    public String getDepDesc() {
        return depDesc;
    }

    /**
     * 设置 部门描述[DEP_DESC]
     *
     * @param depDesc 部门描述
     */
    public void setDepDesc(String depDesc) {
        this.depDesc = depDesc;
    }

    /**
     * @return 创建时间
     */
    @Column(name = "CREATE_TIME")
    public long getCreateTime() {
        return createTime;
    }

    /**
     * 设置 创建时间[CREATE_TIME]
     *
     * @param createTime 创建时间
     */
    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    /**
     * @return 创建人
     */
    @Column(name = "CREATE_ACTOR")
    public long getCreateActor() {
        return createActor;
    }

    /**
     * 设置 创建人[CREATE_ACTOR]
     *
     * @param createActor 创建人
     */
    public void setCreateActor(long createActor) {
        this.createActor = createActor;
    }

    /**
     * @return 修改时间
     */
    @Column(name = "UPDATE_TIME")
    public long getUpdateTime() {
        return updateTime;
    }

    /**
     * 设置 修改时间[UPDATE_TIME]
     *
     * @param updateTime 修改时间
     */
    public void setUpdateTime(long updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * @return 修改人
     */
    @Column(name = "UPDATE_ACTOR")
    public long getUpdateActor() {
        return updateActor;
    }

    /**
     * 设置 修改人[UPDATE_ACTOR]
     *
     * @param updateActor 修改人
     */
    public void setUpdateActor(long updateActor) {
        this.updateActor = updateActor;
    }

    /**
     * @return 排序
     */
    @Column(name = "SORT")
    public int getSort() {
        return sort;
    }

    /**
     * 设置 排序[SORT]
     *
     * @param sort 排序
     */
    public void setSort(int sort) {
        this.sort = sort;
    }

}